<template>
	<view :class="Visible ? 'usable-coupon open' : 'usable-coupon close'">
		<view class="popup-bg" @click="closePopup"></view>
		<view class="main" v-on:click.stop>
			<view class="title">
				<view class="top f42">先用后付</view>
				<view class="desc f28">
					<image src="../../../../static/icon/zmxx.png" mode="widthFix"></image>
					<text>芝麻分≥550可享</text>
				</view>
			</view>
			<view class="content">
				<image mode="widthFix" class="line" src="../../../../static/icon/line.png"/>
				<view class="item">
					<view class="tit">0元先下单</view>
					<view class="desc">购物时选择有「先用后付」标签商品</view>
				</view>
				<view class="item">
					<view class="tit">0订单完成再付款</view>
					<view class="desc">确认收货后，订单将变为完成状态，届时将通过你的支付宝账户自动扣款。</view>
				</view>
			</view>
			<button class="confirm-btn" @click="buy">立即下单</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				/*手机高度*/
				phoneHeight: 0,
				/*可滚动视图区域高度*/
				scrollviewHigh: 0,
				/*是否可见*/
				Visible: false,
				/*优惠券列表*/
				datalist: {},
				/*尺寸比例*/
				ratio: 1
			};
		},
		props: ['isCoupon', 'couponList', 'discount'],

		onLoad() {},
		mounted() {
			this.init();
		},
		watch: {
			isCoupon: function(n, o) {
				if (n != o) {
					this.Visible = n;
					// this.datalist = this.couponList;
					// this.getHeight();
				}
			}
		},
		methods: {
			buy(){
				this.Visible = false
				this.$emit('handleBuy')
			},
			/*初始化*/
			init() {
				let self = this;
				uni.getSystemInfo({
					success(res) {
						self.phoneHeight = res.windowHeight;
						self.ratio = res.windowWidth / 750;
						self.getHeight();
					}
				});
			},
			/*获取高度*/
			getHeight() {
				// let count = Object.keys(this.couponList).length;
				// if (count > 2) {
				// 	this.scrollviewHigh = this.phoneHeight * 0.5;
				// } else {
				// 	if (count == 1) {
				// 		this.scrollviewHigh = 250 * this.ratio + 60;
				// 	} else if (count == 2) {
				// 		this.scrollviewHigh = 460 * this.ratio + 60;
				// 	}
				// }
			},
			
			/*关闭弹窗*/
			closePopup() {
				this.$emit('close');
			}
		}
	};
</script>

<style lang="scss" scoped>
	.title{
		text-align: center;
		margin-top: 80rpx;
		.top{
			font-weight: 500;
		}
		.desc{
			margin-top: 20rpx;
			color: #1677ff;
			image{
				width: 40rpx;
				display: inline-block;
			}
		}
	}
	.content{
		width: 95%;
		margin: 40rpx auto;
		background-color: #fff;
		border-radius: 10rpx;
		padding: 50rpx 50rpx 50rpx 100rpx;
		box-sizing: border-box;
		position: relative;
		.line{
			position: absolute;
			top: 60rpx;
			left: 50rpx;
			width: 15rpx;
		}
		.item{
			margin-bottom: 50rpx;
		}
		.tit{
			color: #333333;
			font-size: 32rpx;
			margin-bottom: 15rpx;
		}
		.desc{
			color: #666666;
			font-size: 28rpx;
		}
	}
	.confirm-btn {
		width: 710rpx;
		height: 80rpx;
		@include background_linearmore('cart_right1', 'cart_right2', 'right_deg', 0%, 100%);
		
		border-radius: 40rpx;
		margin: 0 auto;
		margin-bottom: 55rpx;
		color: #ffffff;
		line-height: 80rpx;
		font-size: 32rpx;
		background-color: #FF7A04;
	}
	.usable-coupon .popup-bg {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		background: rgba(0, 0, 0, 0.6);
		z-index: 99;
		height: 100vh;
		width: 100vw;
	}

	.usable-coupon .main {
		position: fixed;
		width: 100%;
		bottom: 0;
		min-height: 200rpx;
		max-height: 1200rpx;
		background-color: #fff;
		transform: translate3d(0, 980rpx, 0);
		transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
		padding-bottom: env(safe-area-inset-bottom);
		border-radius: 15rpx 15rpx 0 0;
		z-index: 99;
	}

	.usable-coupon .main {
		position: fixed;
		width: 100%;
		bottom: 0;
		min-height: 200rpx;
		// max-height: 900rpx;
		background-color: #fff;
		// transform: translate3d(0, 980rpx, 0);
		transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
		background: linear-gradient(180deg, rgb(209, 244, 255) 0%, #FFFFFF 100%);
		height: 50vh;
		z-index: 99;
	}

	.usable-coupon.open .main {
		transform: translate3d(0, 0, 0);
	}
	.usable-coupon.close .main{
		display: none;
	}
	.usable-coupon.close .popup-bg {
		display: none;
	}

	.coupon-item-red .operation {
		/* background: #fdf1df; */
	}

	.coupon-btns .btn-cancel {
		height: 88rpx;
		line-height: 88rpx;
		font-size: 30rpx;
		background: #999999;
		color: #ffffff;
		border-radius: 0;
	}

	.coupon-item .w100 {
		padding: 0 75rpx;
	}

	.b-radio {
		border: 1rpx solid #FFFFFF;
		border-radius: 30rpx;
		padding: 10rpx 30rpx;
	}

	.range_item {
		border: 1rpx solid #D9D9D9;
		border-top: none;
		padding: 8rpx;
		border-bottom-left-radius: 10rpx;
		border-bottom-right-radius: 10rpx;
		color: #666666;
		box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.1);
	}

	.text-sheng {
		display: inline-block;
		width: 26rpx;
		height: 28rpx;
		background: linear-gradient(180deg, #FF5649 0%, #FF5649 100%);
		border-radius: 3rpx;
		font-size: 18rpx;
		font-family: PingFangSC;
		font-weight: 500;
		color: #FFFFFF;
		text-align: center;
		line-height: 28rpx;
	}

	.text-box {
		padding: 2rpx 6rpx;
		background-color: #fbe9e7;
		color: #fd5342;
		margin-right: 10rpx;
		border-radius: 4rpx;
		font-size: 20rpx;
	}

	.line-h-50 {
		line-height: 50rpx;
	}

	.pop-title {
		padding-top: 53rpx;
		font-size: 28rpx;
		font-family: PingFangSC;
		font-weight: 500;
		color: #333333;
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-bottom: 50rpx;
	}

	.pop-close {
		position: absolute;
		right: 20rpx;
		top: 20rpx;
		font-size: 22rpx;
		color: #999999;
	}

	.scroll-coupon {
		margin: 0 20rpx;
		border-top: 1rpx solid #EEEEEE;
		width: 710rpx;
		box-sizing: border-box;
	}

	.scroll-coupon-tit {
		height: 74rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		font-size: 24rpx;
		color: #999999;
	}
</style>
